package com.kc.data.common.utils;

import cn.hutool.core.date.DateUtil;

import java.util.Date;

/**
 * @ClassName CommonUtil
 * @Description 公共方法
 * @Author wangdongliang
 * @Date 2021/4/28 12:02
 */
public class CommonUtil {

    /**
     * 校验密码合法性
     * @param password
     * @return
     */
    public static boolean checkPass(String password){
         String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,}$";
         return password.matches(PW_PATTERN);
    }
    /**
     * 获取日期对应星期
     * @param date
     * @return
     */
    public static String getWeek(Date date){
        String[] weekDays = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
        return weekDays[DateUtil.dayOfWeek(date)-1];
    }
}
